package cn.autumnorange.app.scheduletask.provider.service;

import cn.autumnorange.app.common.dto.ResultDto;
import cn.autumnorange.app.scheduletask.provider.entity.CronEntity;
import cn.autumnorange.app.scheduletask.provider.repository.CronJpaRepository;
import cn.autumnorange.app.user.api.CronService;
import cn.autumnorange.app.user.api.dto.CronDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

@Primary
@Service
@Slf4j
public class CronServiceImpl implements CronService {

  @Autowired private CronJpaRepository cronJpaRepository;

  @Override
  public ResponseEntity<ResultDto<CronDto>> getRolesByUserId(long cronId) {
    CronEntity cronEntity = cronJpaRepository.findById(cronId);
    CronDto cronDto = new CronDto();
    BeanUtils.copyProperties(cronEntity, cronDto);
    return ResponseEntity.ok(ResultDto.createDataResult(cronDto));
  }

  //    @Override
  //    public JsonResult addUpdSysUser(InsertSysUserDto insertSysUserDto) {
  //        return null;
  //    }

}
